using System.IO;

namespace Prometheus.Binding.Validation.Rules.Simple
{
    /// <summary>
    /// Is file with provided path exists
    /// </summary>
    public class proFileExistsRule : proValidationRuleBase
    {
        public proFileExistsRule()
        {
            ErrorText = "There is no such file";
        }

        public override void Validate(object value, object dataContext)
        {
            var path = value as string;
            if (!File.Exists(path)) ThrowInvalid();
        }
    }
}